//
//  CLNavigationController.m
//  InterestingVideos
//
//  Created by CoderLey on 2022/8/17.
//

#import "CLNavigationController.h"

@interface CLNavigationController () <UIGestureRecognizerDelegate>

@end

@implementation CLNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    if (@available(iOS 13.0, *)) {
        self.modalPresentationStyle = UIModalPresentationFullScreen;
        UINavigationBar *navigationBar = [UINavigationBar appearance];
        
        UINavigationBarAppearance *scrollEdgeAppearance = [[UINavigationBarAppearance alloc] init];
        scrollEdgeAppearance.backgroundColor = RGBA(249, 250, 252, 1);
        navigationBar.scrollEdgeAppearance = scrollEdgeAppearance;
        [scrollEdgeAppearance setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(12, 12, 12),NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium]}];
//        scrollEdgeAppearance.shadowImage = [JKAPPUtils getStretchCenterPointImage:KImageNamed(@"ic_nav_bg")];
        scrollEdgeAppearance.backgroundImage = KImageNamed(@"ic_nav_bg");
        [scrollEdgeAppearance setShadowImage:[UIImage new]];
        navigationBar.standardAppearance = scrollEdgeAppearance;
    }else{
        
    }
    self.navigationBar.barTintColor = RGBA(249, 250, 252, 1);
    self.navigationBar.tintColor = RGB(12, 12, 12);
    self.navigationBar.translucent = NO;
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(12, 12, 12),NSFontAttributeName:[UIFont systemFontOfSize:18 weight:UIFontWeightMedium]}];
    UIBarButtonItem *barItemInNavigationBarAppearanceProxy = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]];
    [barItemInNavigationBarAppearanceProxy
     setTitleTextAttributes:[NSDictionary
                             dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17.f], NSFontAttributeName,RGB(12, 12, 12),NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
    
    
//   // 隐藏导航栏线条
    [[UINavigationBar appearance] setBackgroundImage:KImageNamed(@"ic_nav_bg") forBarMetrics:UIBarMetricsDefault];
//    [[UINavigationBar appearance] setShadowImage:KImageNamed(@"ic_nav_bg")];
//    [self.navigationBar setBackgroundImage:[JKAPPUtils getStretchCenterPointImage:KImageNamed(@"ic_nav_bg")] forBarMetrics:UIBarMetricsDefault];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.interactivePopGestureRecognizer.enabled = NO;
    }
    if (self.pushViewControllBlock) {
        self.pushViewControllBlock();
    }
    if (self.childViewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:YES];
}


-(void)showlllJKAPPGroupdf{
    UIView * _userView = [[UIView alloc]initWithFrame:CGRectMake(0, Ratio(290), K_AUTOLAYOUT_W(375), Ratio(360))];
    _userView.backgroundColor = [UIColor whiteColor];
    _userView.layer.cornerRadius = 8;
    
    
    
    UIImageView * _user_img = [[UIImageView alloc]initWithFrame:CGRectMake(K_AUTOLAYOUT_W(157.5), K_AUTOLAYOUT_W(260), K_AUTOLAYOUT_W(60), K_AUTOLAYOUT_W(60))];
    _user_img.layer.cornerRadius = K_AUTOLAYOUT_W(30);
    _user_img.clipsToBounds = YES;
    _user_img.contentMode = UIViewContentModeScaleAspectFill;
    [_userView addSubview:_user_img];
    
    UILabel * _user_name = [[UILabel alloc]initWithFrame:CGRectMake(K_AUTOLAYOUT_W(15), K_AUTOLAYOUT_W(35), K_AUTOLAYOUT_W(345), K_AUTOLAYOUT_W(25))];
    _user_name.font = FontBold(18);
    _user_name.textColor = ThreeColor;
    _user_name.textAlignment = NSTextAlignmentCenter;
    [_userView addSubview:_user_name];
}
- (void)ljjfslalkjjdf:(NSDate *)nowDate{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
    NSString *dateStr = [formatter stringFromDate:nowDate];
    NSLog(@"字符串时间 = %@", dateStr);
}
- (void)jalkdfjpjlkjlafdf:(NSString *)jkappstr{
    NSMutableArray *aryTemp = [NSMutableArray new];
    for (int i = 0; [aryTemp count] < 9; i++) {
       int RandomNumber;
       do {
          RandomNumber = arc4random() % 9;
       }
        while ([aryTemp containsObject:[NSNumber numberWithInt:RandomNumber]]);
       [aryTemp addObject:[NSNumber numberWithInt:RandomNumber]];
    }
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self forbiddenSideBack];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self resetSideBack];
}

#pragma mark -- 禁用边缘返回
-(void)forbiddenSideBack{

    self.isCanBack = NO;

     //关闭ios右滑返回

    if([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.interactivePopGestureRecognizer.delegate=self;

    }

}

#pragma mark --恢复边缘返回
- (void)resetSideBack {

    self.isCanBack=YES;

    //开启ios右滑返回

    if([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.interactivePopGestureRecognizer.delegate = nil;

    }

}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {

    return self.isCanBack;

}


@end
